package br.edu.infnet.avaliacao.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "curso", catalog = "avaliacao")
public class Curso implements java.io.Serializable {

	private static final long serialVersionUID = -8436028318322943209L;
	private Integer id;
	private Disciplina disciplina;
	private Professor professor;
	private Date dataInicio;
	private Date dataFinal;
	private String sala;
	private Set<Matricula> matriculas = new HashSet<Matricula>(0);
	private Set<Agendamento> agendamentos = new HashSet<Agendamento>(0);

	public Curso() {
	}

	public Curso(Disciplina disciplina, Professor professor, Date dataInicio,
			Date dataFinal, String sala) {
		this.disciplina = disciplina;
		this.professor = professor;
		this.dataInicio = dataInicio;
		this.dataFinal = dataFinal;
		this.sala = sala;
	}

	public Curso(Disciplina disciplina, Professor professor, Date dataInicio,
			Date dataFinal, String sala, Set<Matricula> matriculas,
			Set<Agendamento> agendamentos) {
		this.disciplina = disciplina;
		this.professor = professor;
		this.dataInicio = dataInicio;
		this.dataFinal = dataFinal;
		this.sala = sala;
		this.matriculas = matriculas;
		this.agendamentos = agendamentos;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "disciplina_id", nullable = false)
	public Disciplina getDisciplina() {
		return this.disciplina;
	}

	public void setDisciplina(Disciplina disciplina) {
		this.disciplina = disciplina;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "professor_id", nullable = false)
	public Professor getProfessor() {
		return this.professor;
	}

	public void setProfessor(Professor professor) {
		this.professor = professor;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "data_inicio", nullable = false, length = 10)
	public Date getDataInicio() {
		return this.dataInicio;
	}

	public void setDataInicio(Date dataInicio) {
		this.dataInicio = dataInicio;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date_final", nullable = false, length = 10)
	public Date getDataFinal() {
		return this.dataFinal;
	}

	public void setDataFinal(Date dataFinal) {
		this.dataFinal = dataFinal;
	}

	@Column(name = "sala", nullable = false, length = 30)
	public String getSala() {
		return this.sala;
	}

	public void setSala(String sala) {
		this.sala = sala;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "curso")
	public Set<Matricula> getMatriculas() {
		return this.matriculas;
	}

	public void setMatriculas(Set<Matricula> matriculas) {
		this.matriculas = matriculas;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "curso")
	public Set<Agendamento> getAgendamentos() {
		return this.agendamentos;
	}

	public void setAgendamentos(Set<Agendamento> agendamentos) {
		this.agendamentos = agendamentos;
	}

}

